﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using UniversityStudentManagemnetSystem.DAO.DAL;
using UniversityStudentManagemnetSystem.DAO.DAL.Gateway;

namespace UniversityStudentManagemnetSystem.BLL
{
    public class CreditManager:Manager
    {
        public Credit GetCreditsOf(Teacher aTeacher)
        {
            Credit credit = new Credit();

            CreditGateway creditGateway = new CreditGateway();
            credit.AssignedCredits = creditGateway.GetAssignedCreditOf(aTeacher.Id);

            DataTable performaingCreditTable = creditGateway.GetperformingCreditsOf(aTeacher.Id);

            if (performaingCreditTable.Rows.Count > (int)Rows.noRowCounted)
            {
                foreach (DataRow row in performaingCreditTable.Rows)
                {
                    credit.PerformingCredits += Convert.ToDouble(row["Credit"]);
                }
            }

            return credit;
        }
    }
}